name: test

on:
  push:
    branches:
      - '*'

permissions:
  contents: read

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0 # important!

      - name: Validate composer.json and composer.lock
        run: composer validate --strict

      - name: Cache Composer packages
        id: composer-cache
        uses: actions/cache@v3
        with:
          path: vendor
          key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
          restore-keys: |
            ${{ runner.os }}-php-

      - name: remove bitrix merge-plugin
        run: composer config --unset extra.merge-plugin

      - name: Install dependencies
        run: composer install --prefer-dist --no-progress

      - name: Run PHP_CodeSniffer
        run: composer test:phpcs

      - name: Run PHP-Lint
        run: composer test:phplint
